package com.ruoyi.web.dao.BT;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.web.domain.BT.SuggestEntity;
import com.ruoyi.web.domain.BT.SuggestVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author yzr
 */
@Mapper
public interface SuggestDao extends BaseMapper<SuggestEntity> {


    @Select("SELECT keyword AS suggest, COUNT(*) AS count " +
            "FROM t_suggest WHERE keyword LIKE #{searchStr} " +
            "GROUP BY keyword " +
            "ORDER BY count DESC, keyword DESC LIMIT 10")
    List<SuggestVo> getSuggestions(@Param("searchStr") String searchStr);

}
